package com.wdy.service.impl;

import java.util.List;

import com.wdy.dao.ParkDao;
import com.wdy.po.Page;
import com.wdy.po.Park;
import com.wdy.po.Result;
import com.wdy.service.ParkManager;
import com.wdy.util.PageUtil;

public class ParkManagerImpl implements ParkManager {

	private ParkDao parkDao;
	
	public void setParkDao(ParkDao parkDao) {
		this.parkDao = parkDao;
	}

	
	public void savePark(Park park) {
		parkDao.save(park);
	}

	
	public void removePark(Park park) {
		parkDao.delete(park);
	}

	
	public void updatePark(Park park) {
		parkDao.attachDirty(park);
	}

	
	public Park getPark(Integer id) {
		return parkDao.findById(id);
	}


	public List<Park> listAll() {
		return parkDao.findAll();
	}

	
	public List<Park> findByExample(Park park) {
		return parkDao.findByExample(park);
	}


	public List<Park> findByLocation(String value) {
		return parkDao.findByLocation(value);
	}

	public Result listPark(Page page) {
		int totalRecords = this.parkDao.getParkCount();
		page = PageUtil.createPage(page, totalRecords);
		List<Park> parks = (List<Park>)this.parkDao.getParkByPage(page);     
		return new Result(page, parks);
	}

}
